<?php
namespace Home\Controller;
use Think\Controller;
class ProductsController extends Controller {
	public function index(){

		if(isset($_SESSION['username'])){
        	$this->assign('login','true');
        	$this->assign('username',$_SESSION['username']);
        }

        //当前登录用户的id
        $userid=$_SESSION['id'];

         //获取购物车中物品的总数量
        $cart = D('cart');
        $count = $cart->where("userid='$userid' ")->count();
        $this->assign('count',$count);

        //获取跳转URL
        $type = $_GET[type]; // 分类

        //获取所有的书籍
        $allphone = D('phone');
        $allphoneArr = $allphone ->where("type = '$type' ")->select();
        $this ->assign('allphoneArr',$allphoneArr);


        /*//获取指定分类的shangping
        $spcBook=$allbook->where("id = '$bookId'")->select();
        $this->assign('spcBook',$spcBook);

        //获取精彩专题分类的所有书籍
        $wontypeBook=$allbook->where("type = '精彩' ")->select();
        $this->assign('wontypeBook',$wontypeBook);

        //获取相关书籍relate
        $type = $allbook->where("id = '$bookId'")->getField('type');//当前id所属的分类
        $relateBook=$allbook->where("type = '$type' ")->select();
        $this->assign('relateBook',$relateBook);*/

  

		$this->display();
	}

     //退出
    public function doLogout(){
        $_SESSION = array();
        if(isset($_COOKIE[session_name()])){
            setcookie(session_name(),'',time()-1,'/');
        }
        session_destroy();
        $this->redirect('Index/index');
    }
}